function stoperror(){
	return true ;
}
//window.onerror=stoperror;
//checkbox
function agent(u){
    return true;//(window.navigator.userAgent.indexOf(u) > 0) ? true:false;
}
function leastOneCheck(){
	if (!atleaseOneCheck()){
        	if(locale=="zh_CN")
            	alert("\u81f3\u5c11\u8981\u9009\u62e9\u4e00\u6761\u6570\u636e!");
            else
            	alert("Choose one at least: data entity!");
            return false;
    }
    return true;
}
function atleaseOneCheck(){
    var items = document.getElementsByName("itemlist");
    if(typeof items=="object"){
    	if(typeof items.length =="number"){
    		for (var i = 0; i < items.length; i++)
    		{
        		if (items[i].checked == true)
        		{
            		return true;
        		}
    		}
    	}else{
    		if(document.all.itemlist.checked==true){
    			return true;
    		}
    	}
    }
    return false;
}
function onlyOneCheck(){
	var id;
    var items =document.getElementsByName("itemlist");
    if(typeof items=="object"){
    	if(typeof items.length =="number"){
    		var checked=0;
    		for (var i = 0; i < items.length; i++)
    		{
        		if (items[i].checked == true)
        		{
            		checked++;
            		id=items[i].value+"";
        		}
    		}
    		if(checked==0){
    			if(locale=="zh_CN")
    				alert("\u81f3\u5c11\u8981\u9009\u62e9\u4e00\u6761\u6570\u636e!");
    			else
    				alert("Choose one at least!");
    			return false;
    		}
    		if(checked>1){
    			if(locale=="zh_CN")
    				alert("\u53ea\u80fd\u9009\u62e9\u4e00\u6761\u6570\u636e!");
    			else
    				alert("Can only choose one!");
    			return false;
    		}else {
    			return id;
    		}
    	}else{
    		if(document.all.itemlist.checked==true){
    			return document.all.itemlist.value;
    		}else{
    			if(locale=="zh_CN")
    				alert("\u81f3\u5c11\u8981\u9009\u62e9\u4e00\u6761\u6570\u636e!");
    			else
    				alert("Choose one at least!");
    			return false;
    		}
    	}
    }
    return false;
}
function onlyOneCheckWithOperateName(operateName){
	var id;
    var items = document.getElementsByName("itemlist");
    if(typeof items=="object"){
    	if(typeof items.length =="number"){
    		var checked=0;
    		for (var i = 0; i < items.length; i++){
        		if (items[i].checked == true){
            		checked++;
            		id=items[i].value+"";
        		}
    		}
    		if(checked==0){
    			if(locale=="zh_CN")
    				alert("\u81f3\u5c11\u8981\u9009\u62e9\u4e00\u6761\u6570\u636e!!");
    			else
    				alert("Choose one at least!");
    			return false;
    		}
    		if(checked>1){
    			if(locale=="zh_CN")
    				alert("\u6bcf\u6b21\u53ea\u80fd\u64cd\u4f5c\u4e00\u6761\u6570\u636e!");
    			else
    				alert("Can only each time!");
    			return false;
    		}else {
    			return id;
    		}
    	}else{
    		if(document.all.itemlist.checked==true){
    			return document.all.itemlist.value;
    		}else{
    			if(locale=="zh_CN")
    				alert("\u81f3\u5c11\u8981\u9009\u62e9\u4e00\u6761\u6570\u636e!");
    			else
    				alert("Choose one at least !");
    			return false;
    		}
    	}
    }
    return false;
}

function edit(form,action){
   if(typeof form=='string'){
   	 action=form;
   	 form=document.forms[0];
   }
   var id=onlyOneCheck();
   if(id!=false){
   		resetEc(form);
       	form.action = action;
        form.submit();
   }
}
function create(form,action){	
	if(typeof form=='string'){
   	 action=form;
   	 form=document.forms[0];
    }
    form.action = action;
    form.submit();
    
}

function editParam(form,urlParam,id){
	var param=urlParam.split("&");
	for(i=0;i<param.length;i++){
		oneParam=param[i];
		var one=oneParam.split("=");
        var newElement=document.createElement("input");
        newElement.setAttribute("type","hidden");
        newElement.setAttribute("name",one[0]);
        if(one[1]=="")
        	newElement.setAttribute("value",id);
        else
        	newElement.setAttribute("value",one[1]);
        form.appendChild(newElement);
	}
}
//Reset the ec_eti value, the clearance establishes after export pdf(or xls etc.) of ec_eti value
function resetEc(form){
	if(form==null){   	 
   	 form=document.forms[0];
    }
	if(typeof form.ec_eti=="object"){
   		form.ec_eti.value="";
   	}else if(typeof form.ec_i=="object"){
   		form.ec_i.value="";
   	}
}
//Search before call this function, reset the current page number to 1
function queryEc(form){
	if(form==null){   	 
   	 form=document.forms[0];
    }
	if(typeof form.ec_eti=="object"){
		ec_table_id=form.ec_eti.value;
		form.ec_eti.value='';
	}
	else if(typeof form.ec_i=="object"){
		ec_table_id=form.ec_i.value;
		form.ec_i.value='';
	}
   	if(ec_table_id==''){
   		ec_table_id=getEcTableId(form);
   	}  
	eval("form."+ec_table_id+"_p").value=1;
}
function getEcTableId(form){
	if(form==null){   	 
   	 form=document.forms[0];
    }
	len=form.elements.length;
	for(i=0;i<len;i++){
		name=form.elements[i].name;
		if(name.indexOf("_ev")>-1){
			return name.substring(0,name.indexOf("_ev"));
		}
	}
}
function query(form,action){	
		if(typeof form=='string'){
   	 		action=form;
   	 		form=document.forms[0];
   		}     
    	resetEc(form);
    	if (agent("MSIE")){
    		var oldaction=form.action;	
    		if(typeof action=="string"){
    			form.action = action;
    		}
    		setAAZoneId(form.getAttribute("name")+'Zone,');
    		setAAFormName(form.getAttribute("name"));
    		ajaxAnywhere.submitAJAX();    	
    	}else{
    		form.submit();
    	}
}
function delItem(form,action){
		if(typeof form=='string'){
   	 		action=form;
   	 		form=document.forms[0];
   		}
        var confirmMag="Are you want to delete ?";
        if(locale=="zh_CN")
        	confirmMag="\u786e\u8ba4\u8981\u5220\u9664 ?";
        if (confirm(confirmMag)){
        	resetEc(form);
        	oldaction=form.action;        	
        	if (agent("MSIE")){
        		form.action = action;
        		setAAZoneId(form.getAttribute("name")+'Zone,');
        		setAAFormName(form.getAttribute("name"));
        		ajaxAnywhere.submitAJAX();        		
        	}else{
        		form.submit();
        	}
        }
}
function batch_del(form,action){
		if(typeof form=='string'){
   	 		action=form;
   	 		form=document.forms[0];
   		}
    	if (!atleaseOneCheck()){
        	if(locale=="zh_CN")
            	alert("\u81f3\u5c11\u8981\u9009\u62e9\u4e00\u6761\u6570\u636e!");
            else
            	alert("Choose one at least!");
            return;
    	}
        var confirmMag="Are you want to delete:";
        if(locale=="zh_CN")
        	confirmMag="\u786e\u8ba4\u8981\u5220\u9664\u6570\u636e\uff1f";
        if (confirm(confirmMag)){        	        	
        	if (agent("MSIE")){
        		oldaction=form.action;    
        		form.action = action;
        		form.method="post";
        		setAAZoneId(form.getAttribute("name")+'Zone,');
        		setAAFormName(form.getAttribute("name"));        		
        		ajaxAnywhere.submitAJAX();
        		form.action =oldaction;
        		return;
        	}else{
        		form.submit();
        	}
        }
}
function del(form,action){
	if(typeof form=='string'){
   	 action=form;
   	 form=document.forms[0];
   	}
    if (!onlyOneCheck())        
        var confirmMag="Are you want to delete:";
        if(locale=="zh_CN")
        	confirmMag="\u786e\u8ba4\u8981\u5220\u9664\u6570\u636e? ";
        if (confirm(confirmMag)){
        	resetEc(form);
        	oldaction=form.action;
        	form.action = action;
        	ajaxAnywhere.submitAJAX();
        	//form.submit();
        	form.action=oldaction;
        }
}
function batch_otherOperation(form, entityName, action){
        if (!atleaseOneCheck()){
            if(locale=="zh_CN")
            	alert("\u81f3\u5c11\u8981\u9009\u62e9\u4e00\u6761\u6570\u636e");
            else
            	 alert("Choose one at least.");
            return;
        }
        form.action = action;
        form.submit();
}
function setEcCheckState(checkboxName,checked){
	var items = document.getElementsByName(checkboxName);
    if(typeof items=="object"){
    	if(typeof items.length =="number"){
    		for (var i = 0; i < items.length; i++){
    			items[i].checked=checked;
    		}
    	}else{
    		document.all.itemlist.checked=checked;
    	}
    }
}
function openwin(url, width, height, scroll){
    if (!document.all){
        document.captureEvents(Event.MOUSEMOVE);
        x = e.pageX + width - 30;
        y = e.pageY + height - 30;
    }else{
        x = document.body.scrollLeft + event.clientX + width - 30;
        y = document.body.scrollTop + event.clientY + height - 30;
    }
    window.open(url, "newWindow", "height=" + height + ", width=" + width + ", toolbar =no, menubar=no, scrollbars=" + scroll + ", resizable=no, location=no, status=no, top=" + y + ", left=" + x + "") //????????????
}